﻿using FileData.Currency;
using FileData.Utils.Currency;
using FileData.Utils.Currency.FileUtils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FileData.DataUtils.ViewUtils
{
    class HtmlClear
    {
        /// <summary>
        /// 清理单个
        /// </summary>
        /// <param name="FilePath"></param>
        public void ClearSingle(string FilePath) {
            ClearSingle(FilePath, new FileNameHelper().CreateFileNameWithChlidFloder(FilePath, "Html清理"));
        }
        /// <summary>
        /// 清理单个
        /// </summary>
        /// <param name="FilePath"></param>
        /// <param name="NewFilePath"></param>
        public void ClearSingle(string FilePath,string NewFilePath) {

            string Content = FileHelper.ReadAllText(FilePath);
            Content = new HtmlHelper().ClearContentAuto(Content);
            FileHelper.WriteUTF8Text(NewFilePath, Content);
        }

        /// <summary>
        /// 批量加密到Base64
        /// </summary>
        /// <param name="FloderPath"></param>
        public void ClearFloder(string FloderPath)
        {
            int CompltedCount = 0;
            List<string> FileList = new FloderNameHelper().GetFullFileNameList(FloderPath);
            foreach (string SingleFile in FileList)
            {
                new PrintLog().PercentLog(FileList.Count, ++CompltedCount);
                ClearSingle(SingleFile);
            }
        }
    }
}
